#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int N = 1005;

int n, m;
int a[N][N];
int dp[N][N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) rep(j, 1, i) { cin >> a[i][j]; }
  per(i, n, 1) rep(j, 1, i) {
    dp[i][j] = a[i][j] + max(dp[i + 1][j], dp[i + 1][j + 1]);
  }
  cout << dp[1][1];
  return 0;
}